<?php
declare (strict_types=1);

namespace app\middleware;

use app\common\constant\ErrorNum;
use app\common\exception\AppException;
use Closure;
use think\facade\Route;
use think\facade\Session;
use think\Request;
use think\response\Redirect;

class CheckLogin
{
    /**
     * 处理请求
     *
     * @param Request $request
     * @param Closure $next
     * @return Response|Redirect
     */
    public function handle(Request $request, Closure $next)
    {
        if (session::has('uid')) {
            return $next($request);
        }
        return \redirect(Route::buildUrl('login/index')->__toString());
    }
}
